<section class="panel">
	<head>
	<header class="bg-success panel-heading font-bold"> Permohonan Legalisir </header>
	<script src="<?php echo base_url();?>js/select2/select2.min.js" cache="false"></script>
	<script type="text/javascript">
	$(document).ready(function(){
		$("select[name=ket_alasan]").change(function(){
			if ($("select[name=ket_alasan]").val() == "Lainnya"){
				$("select[name=verifikator]").val("1");
				$("textarea[name=alasan]").html("");
				$(".ket-alasan").show();
			} else if($("select[name=ket_alasan]").val() == "CPNS Pusat") {
				$("select[name=verifikator]").val("2");
				$("textarea[name=alasan]").html($("select[name=ket_alasan]").val());
				$(".ket-alasan").hide();
			} else if ($("select[name=ket_alasan]").val() != ""){
				$("select[name=verifikator]").val("1");
				$("textarea[name=alasan]").html($("select[name=ket_alasan]").val());
				$(".ket-alasan").hide();
			} else {
				$("select[name=verifikator]").val("");
				$("textarea[name=alasan]").html($("select[name=ket_alasan]").val());
				$(".ket-alasan").hide();
			}
		});
		$(".select2").select2();
		$("select[name=sd]").change(function(){
			if ($("select[name=sd]").val() == ""){
				$("select[name=account1]").prop("disabled", true);
			} else {
				$("select[name=account1]").prop("disabled", false);
			}
		});
		$("select[name=smp]").change(function(){
			if ($("select[name=smp]").val() == ""){
				$("select[name=account2]").prop("disabled", true);
			} else {
				$("select[name=account2]").prop("disabled", false);
			}
		});
		$("select[name=sma]").change(function(){
			if ($("select[name=sma]").val() == ""){
				$("select[name=account3]").prop("disabled", true);
			} else {
				$("select[name=account3]").prop("disabled", false);
			}
		});
		$("input[name=csd]").click(function(){
			if($("input[name=csd]").is(':checked'))
				$(".sd").show();
			else
				$(".sd").hide();
		});
		$("input[name=csmp]").click(function(){
			if($("input[name=csmp]").is(':checked'))
				$(".smp").show();
			else
				$(".smp").hide();
		});
		$("input[name=csma]").click(function(){
			if($("input[name=csma]").is(':checked'))
				$(".sma").show();
			else
				$(".sma").hide();
		});
	});
	
</script>
<style>
 .ket-alasan{
	display:none;
 }
 .sd,.smp,.sma{
	display:none;
 }
</style>
</head>
<body>
	<div class="panel-body">
		<form class="bs-example form-horizontal" data-parsley-validate action="<?php echo site_url('pengajuan/tambahPermohonan2');?>" method = "post" enctype="multipart/form-data">
			<div class="form-group">
				<?php echo form_error("valid"); ?>
				<label class="col-sm-3 control-label">Tanggal permohonan</label>
				<div class="col-sm-8">
					<input class="form-control" name="tanggal_permohonan" data-required="true" type="text" data-date-format="dd-mm-yyyy" value="<?php echo date('d-m-Y');?>" disabled>
				</div>
			</div>
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group">
				<label class="col-sm-3 control-label">Alasan pengajuan</label>
				<div class="col-sm-8">
					<select name="ket_alasan" class="form-control m-b">
						<option value="">Pilih alasan pengajuan</option>
						<option value="STPDN">STPDN</option>
						<option value="CPNS Pusat">CPNS Pusat</option>
						<option value="CPNS Daerah">CPNS Daerah</option>
						<option value="TNI (AD / AL / AU)">TNI (AD / AL / AU)</option>
						<option value="POLRI">POLRI</option>
						<option value="SWASTA">SWASTA</option>
						<option value="Lainnya">Lainnya</option>
					</select>
				</div>
				<label class="col-sm-3 control-label ket-alasan">&nbsp;</label>
				<div class="col-sm-8 ket-alasan">
					<textarea class="form-control" name = "alasan" rows="3"></textarea>
				</div>
				<?php echo form_error("alasan"); ?>
			</div>
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group has-error">
				<label class="col-sm-3 control-label">&nbsp;</label>
				<div class="col-sm-8">
					<div class="checkbox">
					  <label>
						<input type="checkbox" name="csd"> <b>Ajukan legalisir Paket A (SD / MI)</b>
					  </label>
					</div>
				</div>
			</div>
            <?php
			if($pengajuan_sd["JUMLAH"] < 10){
			if(empty($data['TK1'])) :?>
            <div class="form-group sd">
                <label class="col-sm-3 control-label">Upload Ijazah SD/PAKET A</label>
                <div class="col-sm-8">
                    <a class="file-input-wrapper btn btn btn-sm btn-info file-input">
                        Browse <input type="file" id ="file-sd" name="file_1" class="form-control">
                    </a>
                </div>
            </div>      
            <?php endif; ?>
			<div class="form-group sd">
				<label class="col-sm-3 control-label">Nama SD/PAKET A</label>
				<div class="col-sm-8">
					<select class="select2" name="sd" data-required="true" style="width:300px;" <?php if(!empty($data['TK1'])) echo 'disabled'?>>
						<option value="">-- Pilih SD terlebih dahulu --</option>
						<?php
						foreach($sd as $row){
						?>
						<option <?php echo ($data["TK1"] == $row["NAMA"]) ? ("selected") : (""); ?> value="<?php echo $row["NAMA"]; ?>"><?php echo $row["NAMA"]; ?></option>
						<?php
						}
						?>
					</select>
				</div>
			</div>
			<div class="form-group sd">
				<label class="col-sm-3 control-label">Jumlah legalisir</label>
				<div class="col-sm-4">
					<select name="account1" class="form-control m-b" <?php echo ($data["TK1"] == null || $data["TK1"] == "") ? ("disabled") : ("")?>>
						<option value="">Pilih Jumlah lembar</option>
						<option value="1">1</option>
						<option value="2">2</option>
						<option value="3">3</option>
						<option value="4">4</option>
						<option value="5">5</option>
					</select>
				</div>
			</div>
			<?php
			} else {
			?>
			<div class="form-group sd">
				<div class="col-sm-3">&nbsp;</div><div class="col-sm-8"><div class="alert alert-danger" style="margin-top:10px;">Permintaan legalisir untuk Paket A (MI / SD) maksimal <b>hanya 10 kali cetak per bulan</b>.</div></div>
			</div>
			<?
			}
			?>
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group has-error">
				<label class="col-sm-3 control-label">&nbsp;</label>
				<div class="col-sm-8">
					<div class="checkbox">
					  <label>
						<input type="checkbox" name="csmp"> <b>Ajukan legalisir Paket B (SMP / MTs)</b>
					  </label>
					</div>
				</div>
			</div>
            <?php
			if($pengajuan_smp["JUMLAH"] < 10){
			if(empty($data['TK2'])) :
			?>
            <div class="form-group smp">
                <label class="col-sm-3 control-label">Upload Ijazah SMP/PAKET B</label>
                <div class="col-sm-8">
                    <a class="file-input-wrapper btn btn btn-sm btn-info file-input">
                        Browse <input type="file" id ="file-smp" name="file_2" class="form-control">
                    </a>
                </div>
            </div>      
            <?php endif; ?>
			<div class="form-group smp">
				<label class="col-sm-3 control-label">Nama SMP/PAKET B</label>
				<div class="col-sm-8">
					<select class="select2" name="smp" data-required="true" style="width:300px;" <?php if(!empty($data['TK2'])) echo 'disabled'?>>
						<option value="">-- Pilih SMP terlebih dahulu --</option>
						<?php
						foreach($smp as $row){
						?>
						<option <?php echo ($data["TK2"] == $row["NAMA"]) ? ("selected") : (""); ?> value="<?php echo $row["NAMA"]; ?>"><?php echo $row["NAMA"]; ?></option>
						<?php
						}
						?>
					</select>
				</div>
			</div>
			<div class="form-group smp">
				<label class="col-sm-3 control-label">Jumlah legalisir</label>
				<div class="col-sm-4">
					<select name="account2" class="form-control m-b" <?php echo ($data["TK2"] == null || $data["TK2"] == "") ? ("disabled") : ("")?>>
						<option value="">Pilih Jumlah lembar</option>
						<option value="1">1</option>
						<option value="2">2</option>
						<option value="3">3</option>
						<option value="4">4</option>
						<option value="5">5</option>
					</select>
				</div>
			</div>
			<?php
			} else {
			?>
			<div class="form-group smp">
				<div class="col-sm-3">&nbsp;</div><div class="col-sm-8"><div class="alert alert-danger" style="margin-top:10px;">Permintaan legalisir untuk Paket C (MTs / SMP) maksimal <b>hanya 10 kali cetak per bulan</b>.</div></div>
			</div>
			<?
			}
			?>			
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group has-error">
				<label class="col-sm-3 control-label">&nbsp;</label>
				<div class="col-sm-8">
					<div class="checkbox">
					  <label>
						<input type="checkbox" name="csma"> <b>Ajukan legalisir Paket C (MA / SMA / SMK)</b>
					  </label>
					</div>
				</div>
			</div>
            <?php
			if($pengajuan_sma["JUMLAH"] < 10){
			if(empty($data['TK3'])) :
			?>
            <div class="form-group sma">
                <label class="col-sm-3 control-label">Upload Ijazah SMA/PAKET C</label>
                <div class="col-sm-8">
                    <a class="file-input-wrapper btn btn btn-sm btn-info file-input">
                    Browse <input type="file" id ="file-sma" name="file_3" class="form-control">
                    </a>
                </div>
            </div>      
            <?php endif; ?>
			<div class="form-group sma">
				<label class="col-sm-3 control-label">Nama SMA/PAKET C</label>
				<div class="col-sm-8">
					<select class="select2" name="sma" data-required="true" style="width:300px;" <?php if(!empty($data['TK3'])) echo 'disabled'?>>
						<option value="">-- Pilih SMA terlebih dahulu --</option>
						<?php
						foreach($sma as $row){
						?>
						<option <?php echo ($data["TK3"] == $row["NAMA"]) ? ("selected") : (""); ?> value="<?php echo $row["NAMA"]; ?>"><?php echo $row["NAMA"]; ?></option>
						<?php
						}
						?>
					</select>
				</div>
			</div>						
			<div class="form-group sma">
				<label class="col-sm-3 control-label">Jumlah legalisir</label>
				<div class="col-sm-4">
					<select name="account3" class="form-control m-b" <?php echo ($data["TK3"] == null || $data["TK3"] == "") ? ("disabled") : ("")?>>
						<option value="">Pilih Jumlah lembar</option>
						<option value="1">1</option>
						<option value="2">2</option>
						<option value="3">3</option>
						<option value="4">4</option>
						<option value="5">5</option>
					</select>
				</div>
			</div>
			<?php
			} else {
			?>
			<div class="form-group sma">
				<div class="col-sm-3">&nbsp;</div><div class="col-sm-8"><div class="alert alert-danger" style="margin-top:10px;">Permintaan legalisir untuk Paket C (MA / SMA / SMK) maksimal <b>hanya 10 kali cetak per bulan</b>.</div></div>
			</div>
			<?
			}
			?>
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group">
				<label class="col-sm-3 control-label">Penanda tangan</label>
				<div class="col-sm-4">
					<select name="verifikator" class="form-control m-b" disabled>
						<option value="">Pilih alasan pengajuan terlebih dahulu</option>
						<option value="2">Kepala dinas</option>
						<option value="1">Sekretaris</option>
					</select>
				</div>
			</div>
			<div class="form-group">			
				<div class="col-lg-11 control-label">
					<div class="doc-buttons">
                        <a href="<?php echo site_url('pengajuan');?>" class="btn btn-sm btn-info"><i class="fa fa-arrow-circle-left text"></i><span class="text"> Kembali</span></a> 
						<button class="btn btn-sm btn-info"><i class="fa fa-pencil text"></i><span class="text"> Ajukan</span></button>
					</div>
				</div>				
			</div>	
           			
	  </form>
	</div>
</section>